{include file="public/header" /}


<div class="page">
    
        <form id="region_form" method="post" enctype="multipart/form-data">
            <table class="sc-default-table">
                <tbody>
                    <tr class="noborder"> 
                        <td class="required w120">{$Think.lang.country_name}</td>
                        <td class="vatop rowform"><input type="text" class="input-txt" name="country_name" id="country_name" value="{$country.country_name|default=''}" /></td>
                        <td></td>
                    </tr>
                    <tr class="noborder"> 
                        <td class="required w120">{$Think.lang.country_code}</td>
                        <td class="vatop rowform"><input type="text" class="input-txt" name="country_code" id="country_code" value="{$country.country_code|default=''}" /></td>
                        <td></td>
                    </tr>
                    <tr class="noborder"> 
                        <td class="required w120">{$Think.lang.country_order}</td>
                        <td class="vatop rowform"><input type="text" class="input-txt" name="country_order" id="country_order" value="{$country.country_order|default='0'}" /></td>
                        <td></td>
                    </tr>
                    <!--图标-->
                    <tr class="noborder">
                        <td class="required"><label for="">国家图标:</label></td>
                        <td class="vatop rowform">
                            {notempty name="$country.country_icon"}
                            <input type="hidden" value="{$country.country_icon}">
                            <span class="type-file-show">
                        <img class="show_image" src="{$Think.ADMIN_SITE_ROOT}/images/preview.png">
                        <div class="type-file-preview"><img src="{$Think.BASE_SITE_ROOT}/uploads/admin/country/{$country.country_icon}"></div>
                    </span>
                            {/notempty}
                            <span class="type-file-box">
                        <input name="country_icon" type="file" class="type-file-file" id="country_icon" size="30">
                    </span>
                        </td>
                    </tr>

                </tbody>
                <tfoot>
                    <tr class="tfoot">
                        <td></td>
                        <td colspan="15"><input id="submitBtn" class="btn" type="submit" value="提交"/></td>
                    </tr>					
                </tfoot>
            </table>
        </form>
    </div>

<script>
    $(function(){
        var textButton="<input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='' class='type-file-button' />"
        $(textButton).insertBefore("#country_icon");
        $("#country_icon").change(function(){
            $("#textfield1").val($("#country_icon").val());
        });
    });
    //按钮先执行验证再提交表单
    $(function(){
        $("#submitBtn").click(function(){
        if($("#region_form").valid()){
            $("#region_form").submit();
        }
       });
        $('#region_form').validate({
            errorPlacement: function(error, element){
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules : {
                country_name : {
                    required : true
                },
                // country_code : {
                //     required : true
                // },
                country_order : {
                    digits : true,
                    required : true
                }
            },
            messages : {
                country_name : {
                    required : '{$Think.lang.country_name_error}'
                },
                // country_code : {
                //     maxlength : '{$Think.lang.country_code_error}'
                // },
                country_order : {
                    digits : '请输入整数',
                    range : '{$Think.lang.country_order_error}'
                }

            }
        });
    });
</script>